/* NAME
 *  select, pselect, FD_CLR, FD_ISSET, FD_SET, FD_ZERO - 
 *  synchronous I/O multiplexing
 */

/* According to POSIX.1-2001, POSIX.1-2008 */
#include <sys/select.h>

/* According to earlier standards */
#include <sys/time.h>
#include <sys/types.h>
#include <unistd.h>

int select(int nfds, fd_set *readfds, fd_set *writefds,
           fd_set *exceptfds, struct timeval *timeout);

void FD_CLR(int fd, fd_set *set);
int  FD_ISSET(int fd, fd_set *set);
void FD_SET(int fd, fd_set *set);
void FD_ZERO(fd_set *set);

#include <sys/select.h>

int pselect(int nfds, fd_set *readfds, fd_set *write_fds,
            fd_set *except fds, const struct timespec *timeout,
            const sigset_t *sigmask);

struct timeval {
    long tv_sec;    /* seconds */
    long tv_usec;   /* microseconds */
};

struct timespec {
    long tv_sec;    /* seconds */
    long tv_nsec;   /* nanoseconds */
};



/* NAME
 *   poll, ppoll - wait for some event on a file descriptor
 */

#include <poll.h>

int poll(struct poll *fds, nfds_t nfds, int timeout);

#define _GNU_SOURCE
#include <signal.h>
#include <poll.h>

int ppoll(struct pollfd *fds, nfds_t nfds, 
          const struct timespec *tmo_p, const sigset_t *sigmask);

struct pollfd {
    int   fd;       /* file descriptor */
    short events;   /* requested events */
    short revents;  /* returned events */
};



